package com.atguigu.wc.test;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.streaming.api.datastream.DataStream;
import org.apache.flink.streaming.api.environment.StreamExecutionEnvironment;

/**
 * @Author:GaoFei
 * @Description:
 * @Date:Created in 18:11
 * @Modified By:
 */
public class StreamWordCount {
    public static void main(String[] args) throws Exception {
        StreamExecutionEnvironment streamExecutionEnvironment = StreamExecutionEnvironment.getExecutionEnvironment();
        String inputPath = "D:\\1BIGDATA\\spark-streaming\\Flink\\src\\main\\resources\\hello.txt";
        DataStream<String> inputDataStreamSource = streamExecutionEnvironment.readTextFile(inputPath);
        DataStream<Tuple2<String, Integer>> sum = inputDataStreamSource
                .flatMap(new WordCountOffLine.MyFla())
                .keyBy(0)
                .sum(1);
        sum.print() ;

        streamExecutionEnvironment.execute();
    }
}
